﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:k="clr-namespace:personalplaner.common.themes">

    <!-- ************************************************** -->
    <!-- Menu template for the gray style                   -->
    <!-- ************************************************** -->
    
    
    
    <Style x:Key="{x:Type Menu}" TargetType="{x:Type Menu}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Menu}">
                    <Border CornerRadius="1" Padding="0,0,0,0" >
                        <StackPanel ClipToBounds="True" Orientation="Horizontal" IsItemsHost="True"/>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>


    <!-- SimpleStyles: MenuItem -->

    <Style x:Key="{x:Static MenuItem.SeparatorStyleKey}" TargetType="{x:Type Separator}">
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Height" Value="2"/>
        <Setter Property="Margin" Value="0,4,0,4"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Separator}">
                    <StackPanel SnapsToDevicePixels="True" Height="2" >
                        <Rectangle Height="1" Fill="#666" />
                    </StackPanel>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <!-- TopLevelHeader -->
    <ControlTemplate x:Key="{x:Static MenuItem.TopLevelHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border Name="Border" >
            <Border.Background>
                <SolidColorBrush Color="#00DDDDDD" />
            </Border.Background>
            <Grid>
                <ContentPresenter x:Name="Content" TextElement.Foreground="{DynamicResource {x:Static k:ResourceKeys.ForegroundBrush}}" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,0,10,0" ContentSource="Header" RecognizesAccessKey="True" />
                <Popup Name="Popup" Placement="Bottom" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
                    <Border Name="SubmenuBorder" CornerRadius="1" SnapsToDevicePixels="True" Background="#DDDDDD" BorderBrush="#909090" BorderThickness="1" >
                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" Grid.IsSharedSizeScope="True"/>
                    </Border>
                </Popup>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Content" Property="TextElement.Foreground" Value="#FFF" />
                <Setter TargetName="Border" Property="Background" Value="#909090"/>
            </Trigger>
            <Trigger Property="IsSuspendingPopupAnimation" Value="True">
                <Setter TargetName="Popup" Property="PopupAnimation" Value="None" />
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSuspendingPopupAnimation" Value="True" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <Setter TargetName="Border" Property="Background" Value="#909090"/>
                <Setter TargetName="Content" Property="TextElement.Foreground" Value="#FFFFFFFF" />
            </MultiTrigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- TopLevelItem -->

    <ControlTemplate x:Key="{x:Static MenuItem.TopLevelItemTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border Name="Border" >
            <Border.Background>
                <SolidColorBrush Color="#00DDDDDD" />
            </Border.Background>
            <ContentPresenter x:Name="Content" TextElement.Foreground="#80FFFFFF" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="10,-1,10,1" ContentSource="Header" RecognizesAccessKey="True" />
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Content" Property="TextElement.Foreground" Value="#FFF" />
                <Setter TargetName="Border" Property="Background" Value="#909090"/>
            </Trigger>
            <MultiTrigger>
                <MultiTrigger.Conditions>
                    <Condition Property="IsSuspendingPopupAnimation" Value="True" />
                    <Condition Property="IsHighlighted" Value="True" />
                </MultiTrigger.Conditions>
                <Setter TargetName="Border" Property="Background" Value="#909090"/>
                <Setter TargetName="Content" Property="TextElement.Foreground" Value="#FFFFFFFF" />
            </MultiTrigger>

        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- SubmenuItem -->

    <ControlTemplate x:Key="{x:Static MenuItem.SubmenuItemTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border Name="Border" Background="Transparent" >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
                    <ColumnDefinition Width="13"/>
                </Grid.ColumnDefinitions>
                <ContentPresenter x:Name="Icon" Margin="6,4,6,4" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Icon"/>
                <Border Name="Check" Width="13" Height="13" Visibility="Collapsed" Margin="6,2,6,2" Background="Transparent" HorizontalAlignment="Center">
                    <Path Name="CheckMark" Width="7" Height="7" Visibility="Hidden" SnapsToDevicePixels="False" Stroke="White" StrokeThickness="2" Data="M 0 0 L 7 7 M 0 7 L 7 0" />
                </Border>
                <ContentPresenter Margin="0,4" TextElement.Foreground="{DynamicResource {x:Static k:ResourceKeys.DarkForegroundBrush}}" Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True"/><!--#FFF-->
                <TextBlock x:Name="InputGestureText" TextElement.Foreground="{DynamicResource {x:Static k:ResourceKeys.DarkForegroundBrush}}" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,4,0,4" DockPanel.Dock="Right" />
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsChecked" Value="true">
                <Setter TargetName="CheckMark" Property="Visibility" Value="Visible"/>
            </Trigger>
            <Trigger Property="IsCheckable" Value="true">
                <Setter TargetName="Check" Property="Visibility" Value="Visible"/>
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Border" Property="Background" Value="#909090" />
                <Setter TargetName="HeaderHost" Property="TextElement.Foreground" Value="#FFFFFFFF" />
                <Setter TargetName="InputGestureText" Property="TextElement.Foreground" Value="#FFFFFFFF" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter TargetName="HeaderHost" Property="TextElement.Foreground" Value="#777"/>
                <Setter TargetName="InputGestureText" Property="TextElement.Foreground" Value="#777"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- SubmenuHeader -->

    <ControlTemplate x:Key="{x:Static MenuItem.SubmenuHeaderTemplateKey}" TargetType="{x:Type MenuItem}">
        <Border Name="Border" >
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Icon"/>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" SharedSizeGroup="Shortcut"/>
                    <ColumnDefinition Width="20"/>
                </Grid.ColumnDefinitions>
                <ContentPresenter Name="Icon" Margin="6,0,6,0" VerticalAlignment="Center" HorizontalAlignment="Center" ContentSource="Icon"/>
                <ContentPresenter Margin="0,4" TextElement.Foreground="#FFF" Name="HeaderHost" Grid.Column="1" ContentSource="Header" RecognizesAccessKey="True"/>
                <TextBlock x:Name="InputGestureText" TextElement.Foreground="#FFF" Grid.Column="2" Text="{TemplateBinding InputGestureText}" Margin="5,2,2,2" DockPanel.Dock="Right"/>
                <Path Name="Arrow" Margin="4,0,0,0"  Grid.Column="3" HorizontalAlignment="Left" VerticalAlignment="Center" Data="M 0 0 L 0 7 L 4 3.5 Z" Fill="White" />
                <Popup Name="Popup" HorizontalOffset="-8" Placement="Right" IsOpen="{TemplateBinding IsSubmenuOpen}" AllowsTransparency="True" Focusable="False" PopupAnimation="Fade">
                    <Border Name="SubmenuBorder" CornerRadius="1" SnapsToDevicePixels="True" Background="#DDDDDD" BorderBrush="#909090" BorderThickness="1" >
                        <StackPanel IsItemsHost="True" KeyboardNavigation.DirectionalNavigation="Cycle" />
                    </Border>
                </Popup>
            </Grid>
        </Border>
        <ControlTemplate.Triggers>
            <Trigger Property="Icon" Value="{x:Null}">
                <Setter TargetName="Icon" Property="Visibility" Value="Hidden"/>
            </Trigger>
            <Trigger Property="IsHighlighted" Value="true">
                <Setter TargetName="Border" Property="Background" Value="#909090" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="false">
                <Setter TargetName="HeaderHost" Property="TextElement.Foreground" Value="#777"/>
                <Setter TargetName="InputGestureText" Property="TextElement.Foreground" Value="#777"/>
            </Trigger>
        </ControlTemplate.Triggers>
    </ControlTemplate>

    <!-- MenuItem Style -->

    <Style x:Key="{x:Type MenuItem}" TargetType="{x:Type MenuItem}">
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Style.Triggers>
            <Trigger Property="Role" Value="TopLevelHeader">
                <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelHeaderTemplateKey}}"/>
                <Setter Property="Grid.IsSharedSizeScope" Value="true"/>
            </Trigger>
            <Trigger Property="Role" Value="TopLevelItem">
                <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.TopLevelItemTemplateKey}}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuHeader">
                <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuHeaderTemplateKey}}"/>
            </Trigger>
            <Trigger Property="Role" Value="SubmenuItem">
                <Setter Property="Template" Value="{StaticResource {x:Static MenuItem.SubmenuItemTemplateKey}}"/>
            </Trigger>
        </Style.Triggers>
    </Style>
    
</ResourceDictionary>